const query = require("./index")

module.exports = {
  list(current, pageSize) {
    current = Number(current) || 1
    pageSize = Number(pageSize) || 5
    const start = (current - 1) * pageSize
    // 登录
    const sql = `SELECT b.book_id bookId,b.book_name bookName,b.book_author author,c.book_category_id categoryId,c.book_category_name categoryName,c.pid pid,c.state categoryState,b.book_publish_date publishDate,b.book_publish publish,b.book_collection collection,b.book_price price,b.book_rate rate,b.book_rate_count rateCount,b.book_desc summary,b.book_count 'count',b.book_state state
    FROM book b
    INNER JOIN book_category c
    ON b.book_category_id=c.book_category_id
    ORDER BY bookId DESC
    LIMIT ?,?`

    return query(sql, [start, pageSize])
  },
}
